// https://leetcode.cn/problems/count-number-of-texts/description/

var f = [100001]int{1, 1, 2, 4}
var g = [100001]int{1, 1, 2, 4}
const mod = 1000000007

func init() {
	for i := 4; i < 100001; i++ {
		f[i] = (f[i - 1] + f[i - 2] + f[i - 3]) % mod
		g[i] = (g[i - 1] + g[i - 2] + g[i - 3] + g[i - 4]) % mod
	}
}

func countTexts(pressedKeys string) int {
	ans := 1
    i := 0
    mod := 1000000007
    for i < len(pressedKeys) {
		c := 0
		j := i
		for ; j < len(pressedKeys) && pressedKeys[j] == pressedKeys[i]; j++ {
			c++
		}
		if pressedKeys[i] == '7' || pressedKeys[i] == '9' {
			ans = ans * g[c] % mod
		} else {
			ans = ans * f[c] % mod
		}	
		i = j
	}
    return ans % mod
}